<?php defined('BASEPATH') or exit('No direct script access allowed');

class Module_Groupon extends Module
{

    public $version = '2.0';

    public function info()
    {
        return array(
            'name' => array(
                'vi' => 'Mua hàng theo nhóm'
            ),
            'description' => array(
                'vi' => 'Quản lý Hệ thống mua hàng theo nhóm.'
            ),
            'frontend' => TRUE,
            'backend' => TRUE,
            'skip_xss' => TRUE,
            'menu' => 'content',
        );
    }

    public function install()
    {
        $this->db->query("
        CREATE TABLE IF NOT EXISTS `" . $this->db->dbprefix('groupon_deals') . "` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(250) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `short_title` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
  `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `user_id` bigint(20) NOT NULL,
  `description` text COLLATE utf8_unicode_ci NOT NULL,
  `short_description` text COLLATE utf8_unicode_ci,
  `private_note` text COLLATE utf8_unicode_ci,
  `notice` text COLLATE utf8_unicode_ci,
  `conditions` text COLLATE utf8_unicode_ci,
  `deal_status_id` int(2) unsigned NOT NULL DEFAULT '1',
  `deal_user_count` bigint(20) unsigned NOT NULL DEFAULT '0',
  `star` tinyint(1) DEFAULT NULL,
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `start_date` datetime NOT NULL,
  `end_date` datetime DEFAULT NULL,
  `min_limit` int(11) unsigned NOT NULL,
  `max_limit` int(11) unsigned DEFAULT NULL,
  `min_order` int(11) DEFAULT '1',
  `max_order` int(11) DEFAULT '0',
  `coupon_start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `coupon_expiry_date` datetime DEFAULT '0000-00-00 00:00:00',
  `is_coupon_mail_sent` tinyint(1) unsigned NOT NULL,
  `is_coupon_sms_sent` tinyint(1) DEFAULT NULL,
  `is_subscription_mail_sent` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `slug` (`slug`),
  KEY `deal_status_id` (`deal_status_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB");

    }

    public function uninstall()
    {
        //it's a core module, lets keep it around
        return FALSE;
    }

    public function upgrade($old_version)
    {
        // Your Upgrade Logic
        return TRUE;
    }

    public function help()
    {
        /**
         * Either return a string containing help info
         * return "Some help info";
         *
         * Or add a language/help_lang.php file and
         * return TRUE;
         *
         * help_lang.php contents
         * $lang['help_body'] = "Some help info";
         */
        return TRUE;
    }
}

/* End of file details.php */
